# -*- coding:utf-8 -*-
from flask import request, jsonify, abort
from flask_cors import CORS
import time
from weixin import WeixinPay, WeixinError

from . import app

localTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))

@app.route('/WXUnionOrder', methods=['POST'])
def WXUnionOrde():
    pay = WeixinPay('wx22b68c5321a452f2', '1466068902', 'abc', 'www.baidu.com')#app_id，商户id
    try:
        out_trade_no = pay.nonce_str
        raw = pay.unified_order(trade_type="APP", body=u"测试", out_trade_no=out_trade_no, total_fee=1 )
        print raw
        return jsonify({"raw":raw})
    except WeixinError, e:

        print e.message
        return jsonify({"raw":e.message})


